<template>
	<view>
		<view>加密后的文件是：{{md5s}}</view>
		<view @click="handleAddperson" class="privateButton">点击添加一个用户</view>
		<view>用户Id            | 用户名 | 说明</view>
		<view v-for="(item,index) in personList">
			{{item.id}}  |   {{item.username}}   | {{item.tips}}
		</view>
	</view>
</template>

<script>
	import {getPersons,addPerson} from '@/API/sqlite/person.js'
	export default {
		data() {
			return {
				md5s: '0',
				personList:[]
			}
		},
		onLoad(){
			console.error("storage====",uni.getStorageSync("mysecuritykey").inputcode)
			this.md5s = uni.getStorageSync("mysecuritykey").inputcode;
			getPersons().then(res =>{
				this.personList = res;
			}).catch(err =>{
				console.error("test.vue onLoad,getPersons failed,err is =====",err)
			})
		},
		methods: {
			handleAddperson(){
				var date = new Date().getMilliseconds();
				addPerson("rota","以后主用的账户").then(res => {
					plus.nativeUI.alert("插入成功");
				}).catch(err => {
					plus.nativeUI.alert("插入失败"+err);
				})
				getPersons().then(res =>{
					this.personList = res;
				}).catch(err =>{
					console.error("test.vue onLoad,getPersons failed,err is =====",err)
				})
			},
		}
	}
</script>

<style>
.privateButton{
	border: solid 1px #3F536E;
	background-color: #3F536E;
}
</style>
